<!DOCTYPE html>
<html lang="en">
	<head>
		<title>pos</title>
		<#include "../inc/header.ftl"/>
	</head>

	<body class="no-skin">

		<div class="main-container ace-save-state" id="main-container">

			<div class="main-content">
				<div class="main-content-inner">

					<div class="page-content">
						<div class="row">
							<div class="col-xs-12">
								<table id="MainGrid"></table>
								<div id="toolbar">
									<div style="padding:8px">
                                        流水号：<input id="bankaffirmfind" class="easyui-textbox" style="width:140px">&emsp;
                                        收款账户：<input id="accountnum" name="accountnum">
                                        收款日期：<input id="accountdate" class="easyui-datebox" style="width:140px">&emsp;
                                        <a href="#" onclick="javascript:searchInfo()" class="easyui-linkbutton" iconCls="icon-search">查 询</a>
                                        <a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="javascript:deleteInfo()">删除</a>

                                    </div>
								</div>
							</div>
						</div><!-- /.row -->
					</div><!-- /.page-content -->
                    <div id="SendBox-add" class="ui-dialog-content hide">
                        <div style="padding:8px">
                            复核用户编码：<input id="usercode" class="easyui-textbox" style="width:140px" data-options="required:true" >&emsp;
                            复核用户密码：<input id="userpwd" class="easyui-textbox" style="width:140px" data-options="required:true" >&emsp;
                            <input id="biaoshi" hidden>&emsp;
                            <a href="#" class="easyui-linkbutton" iconCls="icon-redo"  onclick="javascript:pageSendInfo()"><span  id="sendClean"></span></a>
                            <a href="#" class="easyui-linkbutton" iconCls="icon-back" onclick="javascript:cancelInfo()"><span id="sendCleanCan"></span></a>
                        </div>
                        <table id="SendMainGrid"></table>
                    </div>
                </div>
			</div><!-- /.main-content -->
		</div><!-- /.main-container -->

		<!-- basic scripts -->
		<#include "../inc/basicjs.ftl"/>

		<!-- inline scripts related to this page -->
		<script type="text/javascript">
            //列表-------------------------------------------------
			jQuery(function($) {
                listPage();
			});

			function searchInfo() {
				listPage(prefix + '/bill/bankpos/findBankPosPage',1)
			}

            function listPage(url,mark){
			    if(mark==1){
                    var bankaffirm = $('#bankaffirmfind').val();
                    var accountnum = $('#accountnum').val();
                    var accountdate = $('#accountdate').val();
                    // if(accountnum==null||accountnum==''){
                    //     $.messager.alert('提示', '请选择收款账户', 'info');
                    //     return;
                    // }
                }
                // 右侧表格
                $('#MainGrid').datagrid({
                    url:url,
                    checkbox: true,
                    pagination: true,
                    fitColumns:false,
                    striped: true,
                    singleSelect: false,
                    loadMsg: "正在加载数据，请稍后...",
                    queryParams: {accountnum:accountnum,accountdate:accountdate,bankaffirm:bankaffirm},
                    columns:[[
                        {field: 'ck', checkbox: true},
                        {title:'流水号', field: 'bankaffirm',  width: 100},
                        {title: '缴款人', field: 'opaccountname', width: 110},
                        {title: '缴款人账号',	field: 'opaccountnum',width:120},
                        {title: '收款户名',	field: 'accountname',width:150},
                        {title: '收款银行账号', field: 'accountcode', width: 120},
                        {title: '收款银行开户行', field: 'bankname',width:150},
                        {title: '金额', field: 'money', width: 100 },
                        {title: '收款日期', field: 'accountdate', width: 110 },
                        {title: '附言', field: 'postscript', width: 100}
                    ]],
                    toolbar: '#toolbar'
                });

                $(window).resize(function() {
                    $('#MainGrid').datagrid('resize');
                });
            }

            $('#accountnum').combogrid({
                panelWidth:550,
                idField:'accountcode',
                textField:'accountcode',
                url: prefix+'/base/basedata/findBank',
                columns:[[
                    {field: 'ck', checkbox: true},
                    {field:'cantonname',title:'区划',width:80},
                    {field:'accountcode',title:'账号',width:160},
                    {field:'bankname',title:'开户行名称',width:260}
                ]]
            });
            //----------------------- 发送弹窗
            function deleteInfo() {
                var accountnum = $('#accountnum').val();
                var accountdate = $('#accountdate').val();
                if(accountnum==null||accountnum==''){
                    $.messager.alert('提示', '请选择收款账户', 'info');
                    return;
                }
                if(accountdate==null||accountdate==''){
                    $.messager.alert('提示', '请选择收款日期', 'info');
                    return;
                }

                $('#sendClean').text('确认删除');
                $('#sendCleanCan').text('取消删除');

                $( "#SendBox-add" ).removeClass('hide').dialog({
                    title: '&nbsp;确认删除pos信息',
                    iconCls:'icon-add',
                    width: 600,
                    height: 500,
                    modal: true,
                    buttons:[{
                        text:'取消',
                        iconCls:'icon-cancel',
                        width:80,
                        plain:false,
                        handler:function(){$('#SendBox-add').dialog('close')}
                    }]
                });
                var row =null;
                $.ajax({
                    url: prefix +'/bill/bankpos/findBankPosPage',
                    type: 'POST',
                    data: {
                        accountnum: accountnum,
                        accountdate:accountdate
                    },
                    dataType: 'json',
                    success:function(data){
                        row = data;
                    }
                });

                // 右侧表格
                $('#SendMainGrid').datagrid({
                    data:row,
                    fitColumns:false,
                    striped: true,
                    singleSelect: false,
                    loadMsg: "正在加载数据，请稍后...",
                    columns:[[
                        {title:'流水号', field: 'bankcheckid',  width: 100},
                        {title: '缴款人', field: 'opaccountname', width: 110},
                        {title: '缴款人账号',	field: 'opaccountnum',width:120},
                        {title: '收款户名',	field: 'accountname',width:150},
                        {title: '收款银行账号', field: 'accountcode', width: 120},
                        {title: '收款银行开户行', field: 'bankname',width:150},
                        {title: '金额', field: 'money', width: 100 },
                        {title: '收款日期', field: 'accountdate', width: 110 },
                        {title: '附言', field: 'postscript', width: 100}
                    ]],
                });
            }

            //  ----------------确认发送
            function pageSendInfo() {
                var usercode = $('#usercode').val();
                var userpwd = $('#userpwd').val();
                var accountnum = $('#accountnum').val();
                var accountdate = $('#accountdate').val();
                if(usercode==null||usercode==''){
                    $.messager.alert('提示', '请输入用户编码', 'info');
                    return;
                }
                if(userpwd==null||userpwd==''){
                    $.messager.alert('提示', '请输入用户密码', 'info');
                    return;
                }

                $.ajax({
                    url: prefix +'/bill/bankpos/sendDeleteBankPos',
                    type: 'POST',
                    data: {
                        usercode: usercode,
                        userpwd:userpwd,
                        accountnum:accountnum,
                        accountdate:accountdate
                    },
                    dataType: 'json',
                    success:function(data){
                        $.messager.alert('提示', data.msg, 'info');
                    }
                });
            }

            function cancelInfo() {
                $('#SendBox-add').dialog('close')
            }
        </script>
	</body>
</html>
